a = '()'
s = '[]'
d = '{}'
f = '<>'
fgh = input()
stak = []
new_stroka =''
for i in fgh:
    if i in a or i in s or i in d or i in f:
        new_stroka += i
for i in new_stroka:
    if i in '([{<':
        stak.append(i)
    else:
        if len(stak) > 0:
            if i  == ')':
                if stak[-1] == '(':
                    del stak[-1]
                else:
                     print('False')
                     break
            elif i == ']':
                if stak[-1] == '[':
                     del stak[-1]
                else:
                     print('False')
                     break
            elif i == '}':
                if stak[-1] == '{':
                     del stak[-1]
                else:
                     print('False')
                     break
            elif i == '>':
                if stak[-1] == '<':
                     del stak[-1]
                else:
                    print('False')
                    break
        else:
            print('False')
            break
else:
    print('True')
        
                
                    
    
